# there are several ways to create data frames, and here's one:
mydf <- data.frame(
col1=c(1,2,3,4,5,6),
col2=c("a","b","c","a","b","b")
)
mydf
## col1 col2
## 1 1 a
## 2 2 b
## 3 3 c
## 4 4 a
## 5 5 b
## 6 6 b
# here's a handful of common functions you'll call on data frames, in order
# to visually inspect it or to refer to some property it has:
dim(mydf) # a vector of length 2: number of rows, number of cols
## [1] 6 2
nrow(mydf) # number of rows
## [1] 6
ncol(mydf) # number of columns
## [1] 2
str(mydf) # the structure of the data frame
## 'data.frame': 6 obs. of 2 variables:
## $ col1: num 1 2 3 4 5 6
## $ col2: Factor w/ 3 levels "a","b","c": 1 2 3 1 2 2
summary(mydf) # gives useful info about each column
## col1 col2
## Min. :1.00 a:2
## 1st Qu.:2.25 b:3
## Median :3.50 c:1
## Mean :3.50
## 3rd Qu.:4.75
## Max. :6.00
names(mydf) # the names of the columns
## [1] "col1" "col2"